home *** CD-ROM | disk | FTP | other *** search
- package sunw.demo.test;
-
- import java.awt.Button;
- import java.awt.Checkbox;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.GridLayout;
- import java.awt.Label;
- import java.awt.Panel;
- import java.awt.TextField;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.beans.PropertyChangeListener;
- import java.beans.PropertyChangeSupport;
- import java.beans.PropertyVetoException;
- import java.beans.VetoableChangeListener;
- import java.beans.VetoableChangeSupport;
- import java.util.EventObject;
- import java.util.Vector;
-
- public class BridgeTester extends Panel implements ActionListener, KeyListener, MouseListener {
- private int intValue;
- private short shortValue;
- private double doubleValue;
- private float floatValue;
- private char charValue;
- private byte byteValue;
- private boolean booleanValue;
- private String stringValue;
- private long longValue;
- private int[] intArray;
- private double[] doubleArray;
- private String[] stringArray;
- private float[] floatArray;
- private char[] charArray;
- private short[] shortArray;
- private byte[] byteArray;
- private boolean[] booleanArray;
- private TextField intField;
- private TextField doubleField;
- private TextField shortField;
- private TextField floatField;
- private TextField charField;
- private TextField byteField;
- private Checkbox booleanField;
- private TextField stringField;
- private Button event1Button;
- private Button event2Button;
- private Button event3Button;
- private Button event4Button;
- private TextField array1;
- private TextField array2;
- private TextField array3;
- private TextField array4;
- private PropertyChangeSupport changes = new PropertyChangeSupport(this);
- private VetoableChangeSupport vetos = new VetoableChangeSupport(this);
- private Vector listeners = new Vector();
- private Vector actionListeners = new Vector();
-
- public BridgeTester() {
- ((Container)this).setLayout(new GridLayout(6, 4, 10, 10));
- this.event1Button = new Button("Fire Event 1 ");
- this.event1Button.addActionListener(this);
- ((Container)this).add(this.event1Button);
- this.event2Button = new Button("Fire Event 2 ");
- this.event2Button.addActionListener(this);
- ((Container)this).add(this.event2Button);
- this.event3Button = new Button("Fire Event 3 ");
- this.event3Button.addActionListener(this);
- ((Container)this).add(this.event3Button);
- this.event4Button = new Button("Fire Event 4 ");
- this.event4Button.addActionListener(this);
- ((Container)this).add(this.event4Button);
- ((Container)this).add(new Label("Int Value : "));
- this.intField = new TextField();
- this.intField.addKeyListener(this);
- ((Container)this).add(this.intField);
- this.doubleField = new TextField();
- ((Container)this).add(new Label("Double Value : "));
- this.doubleField.addKeyListener(this);
- ((Container)this).add(this.doubleField);
- ((Container)this).add(new Label("Short Value :"));
- this.shortField = new TextField();
- this.shortField.addKeyListener(this);
- ((Container)this).add(this.shortField);
- ((Container)this).add(new Label("Float Value :"));
- this.floatField = new TextField();
- this.floatField.addKeyListener(this);
- ((Container)this).add(this.floatField);
- ((Container)this).add(new Label("Char Value :"));
- this.charField = new TextField();
- this.charField.addKeyListener(this);
- ((Container)this).add(this.charField);
- ((Container)this).add(new Label("Byte Value :"));
- this.byteField = new TextField();
- this.byteField.addKeyListener(this);
- ((Container)this).add(this.byteField);
- ((Container)this).add(new Label("String value :"));
- this.stringField = new TextField();
- this.stringField.addKeyListener(this);
- ((Container)this).add(this.stringField);
- ((Container)this).add(new Label("Boolean Value :"));
- this.booleanField = new Checkbox();
- this.booleanField.addMouseListener(this);
- ((Container)this).add(this.booleanField);
- this.array1 = new TextField();
- ((Container)this).add(this.array1);
- this.array2 = new TextField();
- ((Container)this).add(this.array2);
- this.array3 = new TextField();
- ((Container)this).add(this.array3);
- this.array4 = new TextField();
- ((Container)this).add(this.array4);
- int[] var1 = new int[]{1, 2, 3, 4, 5};
- this.setIntArray(var1);
- double[] var2 = new double[]{1.1, 2.2, 3.3, 4.4, (double)5.5F};
- this.setDoubleArray(var2);
- String[] var3 = new String[]{"TOTO", "s'en", "va", "en", "guerre"};
- this.setStringArray(var3);
- float[] var4 = new float[]{1.01F, 2.02F, 3.03F, 4.04F, 5.05F};
- this.setFloatArray(var4);
- char[] var5 = new char[]{'A', 'B', 'c', 'd', 'E'};
- this.setCharArray(var5);
- byte[] var6 = new byte[]{1, 2, 3, 4, 5};
- this.setByteArray(var6);
- short[] var7 = new short[]{5, 4, 3, 2, 1};
- this.setShortArray(var7);
- boolean[] var8 = new boolean[]{true, false, false, true, false};
- this.setBooleanArray(var8);
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(400, 200);
- }
-
- /** @deprecated */
- public Dimension preferredSize() {
- return this.getPreferredSize();
- }
-
- public void setIntValue(int var1) throws PropertyVetoException {
- int var2 = this.intValue;
- this.vetos.fireVetoableChange("intValue", new Integer(var2), new Integer(var1));
- this.intValue = var1;
- this.intField.setText(String.valueOf(this.intValue));
- this.changes.firePropertyChange("intValue", new Integer(var2), new Integer(var1));
- }
-
- public int getIntValue() {
- return this.intValue;
- }
-
- public void setDoubleValue(double var1) {
- double var3 = this.doubleValue;
- this.doubleValue = var1;
- this.doubleField.setText(String.valueOf(this.doubleValue));
- this.changes.firePropertyChange("doubleValue", new Double(var3), new Double(var1));
- }
-
- public double getDoubleValue() {
- return this.doubleValue;
- }
-
- public void setShortValue(short var1) {
- short var2 = this.shortValue;
- this.shortValue = var1;
- this.shortField.setText(String.valueOf(this.shortValue));
- this.changes.firePropertyChange("shortValue", new Short(var2), new Short(var1));
- }
-
- public short getShortValue() {
- return this.shortValue;
- }
-
- public void setFloatValue(float var1) {
- float var2 = this.floatValue;
- this.floatValue = var1;
- this.floatField.setText(String.valueOf(this.floatValue));
- this.changes.firePropertyChange("floatValue", new Float(var2), new Float(var1));
- }
-
- public float getFloatValue() {
- return this.floatValue;
- }
-
- public void setCharValue(char var1) {
- char var2 = this.charValue;
- this.charValue = var1;
- this.charField.setText(String.valueOf(this.charValue));
- this.changes.firePropertyChange("charValue", new Character(var2), new Character(var1));
- }
-
- public char getCharValue() {
- return this.charValue;
- }
-
- public void setByteValue(byte var1) {
- byte var2 = this.byteValue;
- this.byteValue = var1;
- this.byteField.setText(String.valueOf(this.byteValue));
- this.changes.firePropertyChange("byteValue", new Byte(var2), new Byte(var1));
- }
-
- public void setByteValue(int var1) {
- this.setByteValue((byte)var1);
- }
-
- public byte getByteValue() {
- return this.byteValue;
- }
-
- public void setLongValue(long var1) {
- this.longValue = var1;
- }
-
- public long getLongValue() {
- return this.longValue;
- }
-
- public boolean isBooleanValue() {
- return this.booleanValue;
- }
-
- public void setBooleanValue(boolean var1) {
- boolean var2 = this.booleanValue;
- this.booleanValue = var1;
- this.booleanField.setState(this.booleanValue);
- this.changes.firePropertyChange("booleanValue", new Boolean(var2), new Boolean(var1));
- }
-
- public String getStringValue() {
- return this.stringValue;
- }
-
- public void setStringValue(String var1) {
- String var2 = this.stringValue;
- this.stringValue = var1;
- this.stringField.setText(this.stringValue);
- this.changes.firePropertyChange("stringValue", var2, var1);
- }
-
- public int[] getIntArray() {
- return this.intArray;
- }
-
- public void setIntArray(int[] var1) {
- this.intArray = var1;
- this.array1.setText(String.valueOf(this.intArray[0]));
- this.array2.setText(String.valueOf(this.intArray[1]));
- this.array3.setText(String.valueOf(this.intArray[2]));
- this.array4.setText(String.valueOf(this.intArray[3]));
- }
-
- public void setIntArrayWithIndex(int var1, int var2) {
- this.intArray[var1] = var2;
- }
-
- public int getIntArrayWithIndex(int var1) {
- return this.intArray[var1];
- }
-
- public double[] getDoubleArray() {
- return this.doubleArray;
- }
-
- public void setDoubleArray(double[] var1) {
- this.doubleArray = var1;
- this.array1.setText(String.valueOf(this.doubleArray[0]));
- this.array2.setText(String.valueOf(this.doubleArray[1]));
- this.array3.setText(String.valueOf(this.doubleArray[2]));
- this.array4.setText(String.valueOf(this.doubleArray[3]));
- }
-
- public void setDoubleArrayWithIndex(int var1, double var2) {
- this.doubleArray[var1] = var2;
- }
-
- public double getDoubleArrayWithIndex(int var1) {
- return this.doubleArray[var1];
- }
-
- public String[] getStringArray() {
- return this.stringArray;
- }
-
- public void setStringArray(String[] var1) {
- this.stringArray = var1;
- this.array1.setText(this.stringArray[0]);
- this.array2.setText(this.stringArray[1]);
- this.array3.setText(this.stringArray[2]);
- this.array4.setText(this.stringArray[3]);
- }
-
- public void setStringArrayWithIndex(int var1, String var2) {
- this.stringArray[var1] = var2;
- }
-
- public String getStringArrayWithIndex(int var1) {
- return this.stringArray[var1];
- }
-
- public byte[] getByteArray() {
- return this.byteArray;
- }
-
- public void setByteArray(byte[] var1) {
- this.byteArray = var1;
- this.array1.setText(String.valueOf(this.byteArray[0]));
- this.array2.setText(String.valueOf(this.byteArray[1]));
- this.array3.setText(String.valueOf(this.byteArray[2]));
- this.array4.setText(String.valueOf(this.byteArray[3]));
- }
-
- public void setByteArrayWithIndex(int var1, byte var2) {
- this.byteArray[var1] = var2;
- }
-
- public byte getByteArrayWithIndex(int var1) {
- return this.byteArray[var1];
- }
-
- public float[] getFloatArray() {
- return this.floatArray;
- }
-
- public void setFloatArray(float[] var1) {
- this.floatArray = var1;
- this.array1.setText(String.valueOf(this.floatArray[0]));
- this.array2.setText(String.valueOf(this.floatArray[1]));
- this.array3.setText(String.valueOf(this.floatArray[2]));
- this.array4.setText(String.valueOf(this.floatArray[3]));
- }
-
- public void setFloatArrayWithIndex(int var1, float var2) {
- this.floatArray[var1] = var2;
- }
-
- public float getFloatArrayWithIndex(int var1) {
- return this.floatArray[var1];
- }
-
- public char[] getCharArray() {
- return this.charArray;
- }
-
- public void setCharArray(char[] var1) {
- this.charArray = var1;
- this.array1.setText(String.valueOf(this.charArray[0]));
- this.array2.setText(String.valueOf(this.charArray[1]));
- this.array3.setText(String.valueOf(this.charArray[2]));
- this.array4.setText(String.valueOf(this.charArray[3]));
- }
-
- public void setCharArrayWithIndex(int var1, char var2) {
- this.charArray[var1] = var2;
- }
-
- public char getCharArrayWithIndex(int var1) {
- return this.charArray[var1];
- }
-
- public boolean[] getBooleanArray() {
- return this.booleanArray;
- }
-
- public void setBooleanArray(boolean[] var1) {
- this.booleanArray = var1;
- this.array1.setText(String.valueOf(this.booleanArray[0]));
- this.array2.setText(String.valueOf(this.booleanArray[1]));
- this.array3.setText(String.valueOf(this.booleanArray[2]));
- this.array4.setText(String.valueOf(this.booleanArray[3]));
- }
-
- public void setBooleanArrayWithIndex(int var1, boolean var2) {
- this.booleanArray[var1] = var2;
- }
-
- public boolean getBooleanArrayWithIndex(int var1) {
- return this.booleanArray[var1];
- }
-
- public short[] getShortArray() {
- return this.shortArray;
- }
-
- public void setShortArray(short[] var1) {
- this.shortArray = var1;
- this.array1.setText(String.valueOf(this.shortArray[0]));
- this.array2.setText(String.valueOf(this.shortArray[1]));
- this.array3.setText(String.valueOf(this.shortArray[2]));
- this.array4.setText(String.valueOf(this.shortArray[3]));
- }
-
- public void setShortArrayWithIndex(int var1, short var2) {
- this.shortArray[var1] = var2;
- }
-
- public short getShortArrayWithIndex(int var1) {
- return this.shortArray[var1];
- }
-
- public void printObjectInField(Object var1) {
- if (var1 == null) {
- this.stringField.setText("NULL REF");
- } else {
- this.stringField.setText(var1.toString());
- }
- }
-
- public void addPropertyChangeListener(PropertyChangeListener var1) {
- this.changes.addPropertyChangeListener(var1);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener var1) {
- this.changes.removePropertyChangeListener(var1);
- }
-
- public void addVetoableChangeListener(VetoableChangeListener var1) {
- this.vetos.addVetoableChangeListener(var1);
- }
-
- public void removeVetoableChangeListener(VetoableChangeListener var1) {
- this.vetos.removeVetoableChangeListener(var1);
- }
-
- public synchronized void addBridgeTesterListener(BridgeTesterListener var1) {
- this.listeners.addElement(var1);
- }
-
- public synchronized void removeBridgeTesterListener(BridgeTesterListener var1) {
- this.listeners.removeElement(var1);
- }
-
- public ActionListener getActionListener() {
- return new 1();
- }
-
- private void fireEvent(int var1) {
- synchronized(this){}
-
- Vector var2;
- try {
- var2 = (Vector)this.listeners.clone();
- } catch (Throwable var7) {
- throw var7;
- }
-
- for(int var3 = 0; var3 < var2.size(); ++var3) {
- BridgeTesterListener var4 = (BridgeTesterListener)var2.elementAt(var3);
- switch (var1) {
- case 1:
- BridgeTesterEvent var5 = new BridgeTesterEvent(this, this.stringValue, this.intValue);
- var4.eventNumber1(var5);
- break;
- case 2:
- var4.eventNumber2(this.stringValue);
- break;
- case 3:
- var4.eventNumber3(this.shortValue);
- break;
- case 4:
- var4.eventNumber4(this.intArray);
- }
- }
-
- }
-
- public void actionPerformed(ActionEvent var1) {
- Object var2 = ((EventObject)var1).getSource();
- if (var2 == this.event1Button) {
- this.fireEvent(1);
- } else if (var2 == this.event2Button) {
- this.fireEvent(2);
- } else if (var2 == this.event3Button) {
- this.fireEvent(3);
- } else if (var2 == this.event4Button) {
- this.fireEvent(4);
- }
- }
-
- public void keyPressed(KeyEvent var1) {
- }
-
- public void keyTyped(KeyEvent var1) {
- }
-
- public void keyReleased(KeyEvent var1) {
- Object var2 = ((EventObject)var1).getSource();
- if (var2 == this.stringField) {
- this.setStringValue(this.stringField.getText());
- } else if (var2 == this.doubleField) {
- try {
- double var16 = this.doubleValue;
- this.doubleValue = new Double(this.doubleField.getText());
- this.changes.firePropertyChange("doubleValue", new Double(var16), new Double(this.doubleValue));
- } catch (NumberFormatException var5) {
- this.doubleField.setText(String.valueOf(this.getDoubleValue()));
- }
- } else if (var2 == this.intField) {
- int var15 = this.intValue;
-
- try {
- int var4 = new Integer(this.intField.getText());
- this.vetos.fireVetoableChange("intValue", new Integer(var15), new Integer(var4));
- this.intValue = var4;
- this.changes.firePropertyChange("intValue", new Integer(var15), new Integer(var4));
- } catch (NumberFormatException var6) {
- this.intField.setText(String.valueOf(this.getIntValue()));
- } catch (PropertyVetoException var7) {
- this.intField.setText(String.valueOf(this.getIntValue()));
- }
- } else if (var2 == this.shortField) {
- try {
- short var14 = this.shortValue;
- this.shortValue = new Short(this.shortField.getText());
- this.changes.firePropertyChange("shortValue", new Short(var14), new Short(this.shortValue));
- } catch (NumberFormatException var8) {
- this.shortField.setText(String.valueOf(this.getShortValue()));
- }
- } else if (var2 == this.floatField) {
- try {
- float var13 = this.floatValue;
- this.floatValue = new Float(this.floatField.getText());
- this.changes.firePropertyChange("floatValue", new Float(var13), new Float(this.floatValue));
- } catch (NumberFormatException var9) {
- this.floatField.setText(String.valueOf(this.getFloatValue()));
- }
- } else if (var2 == this.byteField) {
- try {
- byte var12 = this.byteValue;
- this.byteValue = new Byte(this.byteField.getText());
- this.changes.firePropertyChange("byteValue", new Byte(var12), new Byte(this.byteValue));
- } catch (NumberFormatException var10) {
- this.byteField.setText(String.valueOf(this.getByteValue()));
- }
- } else if (var2 == this.charField) {
- try {
- this.setCharValue(this.charField.getText().charAt(0));
- } catch (NumberFormatException var11) {
- char[] var3 = new char[]{this.getCharValue()};
- this.charField.setText(new String(var3));
- }
- }
- }
-
- public void mousePressed(MouseEvent var1) {
- }
-
- public void mouseClicked(MouseEvent var1) {
- }
-
- public void mouseEntered(MouseEvent var1) {
- }
-
- public void mouseExited(MouseEvent var1) {
- }
-
- public void mouseReleased(MouseEvent var1) {
- if (((EventObject)var1).getSource() == this.booleanField) {
- boolean var2 = this.booleanValue;
- boolean var3;
- if (this.booleanValue) {
- var3 = false;
- } else {
- var3 = true;
- }
-
- this.booleanValue = var3;
- this.changes.firePropertyChange("booleanValue", new Boolean(var2), new Boolean(var3));
- }
-
- }
- }
-